package com.huangyuqiang.utils;


/**
 * Created by hyq on 2015/12/15.
 */
public abstract class Entity<TID> {
    private final TID id;

    protected Entity(TID id) {
        if (id == null) {
            throw new IllegalArgumentException("The ID cannot be null.");
        }
        this.id = id;
    }

    public TID getId() {
        return id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Entity<?> entity = (Entity<?>) o;

        return id.equals(entity.id);
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }
}
